package com.iemes.controller.transport;

import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.iemes.annotation.SystemLog;
import com.iemes.controller.index.BaseController;
import com.iemes.entity.TransportMaintaintoolFormMap;
import com.iemes.mapper.transport.TransportMaintaintoolMapper;
import com.iemes.plugin.PageView;
import com.iemes.util.Common;

@RequestMapping("/transportmaintaintool/")
@Controller
public class TransportMaintaintoolController extends BaseController{
	@Inject
	private TransportMaintaintoolMapper transportMaintaintoolMapper;
	
	//车辆维修工具
	@RequestMapping("/examinetransportMaintaintool")
	public String examinetransportMaintaintool(Model model){
		model.addAttribute("res", findByRes());
		return Common.BACKGROUND_PATH+"/transport/maintaintool/transportmaintaintool_list";
	}
	//车辆维修工具分页
	@ResponseBody
	@RequestMapping("/transportMaintaintool_findbyPage")
	public PageView findByPage(String pageNow, String pageSize) throws Exception 
	{
		List<Map<String, Object>> transportMaintaintoolFormMaps = transportMaintaintoolMapper.getAllInfo();
		LuogicPaging(pageNow, pageSize, transportMaintaintoolFormMaps);
		return pageView;
	}
	//删除车辆维修工具
			@ResponseBody
			@RequestMapping("transportMaintaintool_deleteEntity")
			@Transactional(readOnly=false)//需要事务操作必须加入此注解
			@SystemLog(module="删除车辆维修工具",methods="pod按钮-删除pod按钮")//凡需要处理业务逻辑的.都需要记录操作日志
			public String deleteEntity() throws Exception {
				TransportMaintaintoolFormMap transportMaintaintoolFormMap=getFormMap(TransportMaintaintoolFormMap.class);
				String[] ids = getParaValues("ids");
				String arr=ids[0];
				String[] str=arr.split(",");
				for(int i=0;i<str.length;i++){
					transportMaintaintoolFormMap.set("status", 2);
					transportMaintaintoolFormMap.put("id", str[i]);
					transportMaintaintoolMapper.editEntity(transportMaintaintoolFormMap);
				}
				
				return "success";
			}
}
